package com.atguigu.yygh.hosp.receiver;

import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.rabbit.config.MQConst;
import com.atguigu.yygh.vo.order.OrderMqVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA
 *
 * @Date: 2023/1/8 - 14:33
 * @Author: Hyoung
 * @Description:
 */

@Component
@Slf4j
public class HospitalReceiver {

    @Autowired
    private ScheduleService scheduleService;


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MQConst.QUEUE_ORDER, durable = "true"), //定义消息队列，并持久化
            exchange = @Exchange(value = MQConst.EXCHANGE_DIRECT_ORDER), //定义交换机
            key = {MQConst.ROUTING_ORDER} //定义路由
    ))
    public void receiver(OrderMqVo orderMqVo) {
        //修改排班信息
        log.info("HospitalReceiver 监听器监听到消息......");
        scheduleService.updateByOrderMqVo(orderMqVo);
    }
}
